import java.security.PrivateKey;
import java.util.Stack;

public class Test {
    //最小栈

    private Stack<Integer> stack;
    private Stack<Integer> minstack;

    public void MinStack() {
        stack = new Stack<>();
        minstack = new Stack<>();
    }

    public void push(int val) {
        stack.push(val);
        if(minstack.empty()){
            minstack.push(val);
        }else{
            int topVal = minstack.peek();
            if(topVal >= val){
                minstack.push(val);
            }
        }
    }

    public void pop() {
        int top = stack.pop();
        if(top == minstack.peek()){
            minstack.pop();
        }
    }

    public int top() {
        return stack.peek();
    }

    public int getMin() {
        return minstack.peek();
    }

    public static void main(String[] args) {

    }
}
